package com.yc.cloud.cloudindex.web.feign;

import com.yc.cloud.cloudindex.bean.Result;
import com.yc.cloud.cloudindex.bean.User;
import com.yc.cloud.cloudindex.web.hystrix.UserActionImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 用于访问cloud-user 服务的接口
 */
//默认情况下 服务名（cloud-user） 必须全局唯一
@FeignClient(value = "cloud-user",fallback = UserActionImpl.class )
public interface IUserAction {
    //cloud-user/user
    @RequestMapping("user")
    String user();

    /**
     * Feign 接口参数有2种类型
     * 1.@RequestParam  标注 定义地址参数种
     *     http://localhost/add?a=1&b=2
     * 2.@RequestBody  标注 定义在 请求体中
     *    接口中的body 参数只能有一个
     * @param a
     * @param b
     * @return
     */
    @RequestMapping("add")
    int add(@RequestParam int a, @RequestParam int b);

    @RequestMapping("div")
    Result div(@RequestParam int a,@RequestParam int b);

    @RequestMapping("reg")
    Result reg(@RequestBody User user);

    @RequestMapping("div1{num}")
    double div1(@PathVariable int num);

    @RequestMapping("sendVcode")
    String sendVcode();
}
